<template>
  <div class="user-center">
    <Header />
    
    <div class="user-banner">
      <div class="container">
        <h1>个人中心</h1>
        <p>管理您的个人信息、作品和收藏</p>
      </div>
    </div>
    
    <div class="container main-content">
      <el-row :gutter="30">
        <el-col :xs="24" :sm="24" :md="6">
          <el-card class="user-card" shadow="hover">
            <div class="user-avatar">
              <el-avatar :size="100" :src="avatar || defaultAvatar"></el-avatar>
            </div>
            <div class="user-info">
              <h3>{{ nickname }}</h3>
              <p>{{ username }}</p>
            </div>
            <el-menu 
              :default-active="activeMenu" 
              class="user-menu" 
              router>
              <el-menu-item index="/user/profile">
                <i class="el-icon-user"></i>
                <span>个人资料</span>
              </el-menu-item>
              <el-menu-item index="/user/photos">
                <i class="el-icon-picture"></i>
                <span>我的作品</span>
              </el-menu-item>
              <el-menu-item index="/user/votes">
                <i class="el-icon-star-on"></i>
                <span>我的投票</span>
              </el-menu-item>
              <el-menu-item index="/user/comments">
                <i class="el-icon-chat-line-square"></i>
                <span>我的评论</span>
              </el-menu-item>
              <el-menu-item index="/user/likes">
                <i class="el-icon-thumb"></i>
                <span>我的点赞</span>
              </el-menu-item>
              <el-menu-item index="/user/collections">
                <i class="el-icon-collection"></i>
                <span>我的收藏</span>
              </el-menu-item>
              <el-menu-item index="/user/works">
                <i class="el-icon-picture-outline-round"></i>
                <span>作品管理</span>
              </el-menu-item>
              <el-menu-item index="/home">
                <i class="el-icon-back"></i>
                <span>返回首页</span>
              </el-menu-item>
            </el-menu>
          </el-card>
        </el-col>
        <el-col :xs="24" :sm="24" :md="18">
          <div class="content-wrapper">
            <router-view />
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import Header from '@/components/Header.vue'
import { mapGetters } from 'vuex'

export default {
  name: 'UserCenter',
  components: {
    Header
  },
  data() {
    return {
      defaultAvatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
    }
  },
  computed: {
    ...mapGetters(['username', 'nickname']),
    activeMenu() {
      return this.$route.path
    },
    avatar() {
      return this.$store.state.userInfo.avatar
    }
  }
}
</script>

<style scoped>
.user-center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f9f9f9;
}

.user-banner {
  background: linear-gradient(to right, #3498db, #2c3e50);
  color: white;
  padding: 40px 0;
}

.user-banner h1 {
  font-size: 32px;
  margin: 0 0 10px;
  font-weight: 600;
}

.user-banner p {
  margin: 0;
  opacity: 0.9;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.main-content {
  margin: 30px auto;
  flex: 1;
}

.user-card {
  border-radius: 8px;
  margin-bottom: 20px;
  transition: all 0.3s;
  overflow: hidden;
}

.user-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.user-avatar {
  display: flex;
  justify-content: center;
  margin: 25px 0;
}

.user-info {
  text-align: center;
  margin-bottom: 25px;
}

.user-info h3 {
  margin: 10px 0 5px;
  font-size: 20px;
  color: #34495e;
}

.user-info p {
  margin: 0;
  color: #7f8c8d;
  font-size: 14px;
}

.user-menu {
  border-right: none;
}

.user-menu .el-menu-item {
  height: 50px;
  line-height: 50px;
  padding: 0 20px;
  border-radius: 4px;
  margin: 5px 0;
  color: #606266;
}

.user-menu .el-menu-item:hover, .user-menu .el-menu-item:focus {
  background-color: #ecf5ff;
}

.user-menu .el-menu-item.is-active {
  color: #3498db;
  background-color: #ecf5ff;
}

.user-menu .el-menu-item i {
  margin-right: 10px;
  font-size: 18px;
}

.content-wrapper {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  min-height: 500px;
}

@media (max-width: 768px) {
  .main-content {
    margin: 20px auto;
  }
  
  .user-banner {
    padding: 30px 0;
  }
  
  .user-banner h1 {
    font-size: 28px;
  }
  
  .content-wrapper {
    margin-top: 20px;
  }
}
</style> 